<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title>Title</title>
    <link rel="stylesheet" href="__CSS__/pintuer.css">
    <link rel="stylesheet" href="__CSS__/admin.css">
    <link rel="stylesheet" href="__STATIC__/css/layui.css">
    <script src="__STATIC__/layui.js"></script>
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/pintuer.js"></script>
</head>
<body>
<form class="layui-form" action="{:url('Project/schedule_apply_list')}" method="post">
        <div style="margin-top: 10px" class="layui-inline">
            <label class="layui-form-lable">
                搜索：
            </label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" placeholder="输入要搜索的单号" name="id" >
            </div>
        </div>
        <div class="layui-form-item">
            <div style="float: right;margin-top: 2%;margin-right: 10%" class="layui-input-block">
                <button class="layui-btn" name="project_submit" lay-submit="" lay-filter="project_demo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
</form>
    <h3 style="text-align: center;margin-top: 3%;margin-bottom: 2%"><b>工程项目进度列表</b></h3>
    <table id="project" lay-filter="project">
        <thead>
        <tr>
            <th lay-data="{field: 'id', title: '单号', width: 150, align: 'center', sort: true}">昵称</th>
            <th lay-data="{field: 'schedule_name', width: 250, align: 'center', title: '进度名称', sort: true}">加入时间</th>
            <th lay-data="{field: 'project_pay_info', width: 300, align: 'center', title: '付款内容', sort: true}">加入时间</th>
            <th lay-data="{field: 'apply_state', width: 200, align: 'center', title: '审批状态', sort: true}">加入时间</th>
            <th lay-data="{ title: '操作',width:200,align: 'center', toolbar: '#barDemo'}">签名</th>
        </tr>
        </thead>
        <tbody>
        {volist name="$project" id="vo"}
        <tr>
            <td>{$vo.id}</td>
            <td>{$vo.schedule_name}</td>
            <td>{$vo.project_pay_info}</td>
            <td>{$vo.apply_state}</td>
        </tr>
        {/volist}
        </tbody>
    </table>


</body>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">查看详情</a>
    <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除/撤销</a>-->
</script>
<script>
    layui.use(['form','table', 'layedit', 'laydate'], function () {
        var laydate = layui.laydate;
        var form = layui.form;
        var layer = layui.layer;
        var table=layui.table;
        //日期时间选择器
        laydate.render({
            elem: '#created_time'
            , type: 'datetime'
        });
//监听提交
       /* form.on('submit(demo1)', function (data) {
            /!*layer.alert(JSON.stringify(data.field), {
             title: '最终的提交信息'
             });*!/
            var datas = JSON.stringify(data.field);
            //console.log(datas);
            $.ajax({
                type: "post",
                url: "{:url('Project/items')}",
                data: {'data': datas},
                dataType: "json",
                success: function (res) {
                    //alert(res);
                    //console.log(res);
                    if (res == 1) {
                        layer.msg('添加成功');
                        window.setTimeout("window.location=\"{:url('Stafflist/index')}\"", 2000);
                        //window.location.href="{:url('Stafflist/index')}"
                    } else {
                        layer.msg('提示：添加失败');
                    }
                }
            });
            return false;
        });*/


        //监听工具条付款申请
        table.on('tool(project)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                window.location.replace("{:url('Project/schedule_apply_info')}?id=" + data.id)
                //layer.alert('编辑行：<br>' + JSON.stringify(data))
            } else if (obj.event === 'del') {
                //console.log(data.id);
                Projectapprove_del(data.id);
                //layer.close(index);
            }
        });
        //方法渲染table付款申请
        table.init('project',{
            height: 400
            ,initSort: {
                //排序字段，对应 cols 设定的各字段名
                field: 'id'
                //排序方式  asc: 升序、desc: 降序、null: 默认排序
                ,type: 'desc'
            }
            , page: {
                layout: ['count', 'limit', 'prev', 'page', 'next', 'skip']
                , curr: 1
            }
        });
        /*table.render({
            elem: '#project'
            , height: 400
            ,initSort: {
                //排序字段，对应 cols 设定的各字段名
                field: 'id'
                //排序方式  asc: 升序、desc: 降序、null: 默认排序
                ,type: 'desc'
            }
            , url: "{:url('Project/schedule_approve_list')}"
            , cols: [[
                {field: 'id', title: '单号', width: 160, align: 'center', sort: true}
                , {field: 'schedule_name', align: 'center', title: '进度名称', sort: true}
                , {field: 'project_pay_info', align: 'center', title: '付款内容', sort: true}
                , {field: 'apply_state', align: 'center', title: '审批状态', sort: true}
                , {fixed: 'right', title: '操作', align: 'center', toolbar: '#barDemo'}
            ]]
            , id: "test1"
            , page: {
                layout: ['count', 'limit', 'prev', 'page', 'next', 'skip']
                , curr: 1
            }
        });*/

    });
    //所有删除都调这一个方法
    function Projectapprove_del(id) {
        //alert(type_approve);
        layui.use(['layer'], function () {
            var layer = layui.layer;
            layer.confirm('你确定要删除审批记录/撤销正在审批的申请吗?',{icon: 7, title: '提示'}, function (index) {
                $.ajax({
                    type: "post",
                    url: "{:url('Project/schedule_del')}",
                    data: {'id': id},
                    dataType: "json",
                    success: function (i) {
                        console.log(i);
                        if (i) {
                            layer.msg('申请记录删除成功', {icon: 1});
                            layer.close(index);
                        } else {
                            layer.msg('删除申请记录失败', {icon: 2});
                            layer.close(index);
                        }
                        setTimeout(function () {
                            //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                            window.location.reload();//页面刷新
                        }, 2000);
                    }
                });

            });
        });
    }
</script>
</html>